package net.zjitc.io.filestream;


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author admin
 * @Date 2019/4/10 8:26
 */
public class CopyMP4 {
    public static void main(String[] args) {
        try {
            FileInputStream fis = new FileInputStream("D:\\1.mp4");
            FileOutputStream fos = new FileOutputStream("2.mp4");
            int len = 0;
            /*系统当前时间（以毫秒为单位）*/
            long start = System.currentTimeMillis();
            /*读取一个字节，然后写入一个字节*/
           /* while ((len=fis.read())!=-1){
                fos.write(len);
            }*/
            /*一次写入一个字节数组*/
            byte[] bytes = new byte[1024];
            while ((len = fis.read(bytes)) != -1) {
                fos.write(bytes, 0, len);
            }
            long end = System.currentTimeMillis();
            System.out.println("一次读取一个字节数组" + (end - start) + "毫秒");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
